package com.hebeu.gfh.service.impl;

import com.hebeu.gfh.mapper.TextVoteMapper;
import com.hebeu.gfh.pojo.po.TextVote;
import com.hebeu.gfh.pojo.po.voteResult;
import com.hebeu.gfh.pojo.vo.voteInfo;
import com.hebeu.gfh.service.textVoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 刘剑利
 * @Version: v1.0
 */
@Service("textVoteService")
public class textVoteServiceImpl implements textVoteService {
    @Autowired
    TextVoteMapper voteMapper;

    @Override
    public void initTextVote(TextVote textVote) {
        voteMapper.initTextVote(textVote);
    }

    @Override
    public List<TextVote> getVoteList(int userId) {
        List<TextVote> voteList =voteMapper.getVoteList(userId);
        return voteList;
    }

    @Override
    public void deleteVote(int voteId) {
        voteMapper.deleteVote(voteId);
    }

    @Override
    public TextVote findVoteInfoByvid(int vid) {
        TextVote vote =voteMapper.findVoteInfoByvid(vid);
        return vote;
    }

    @Override
    public void updateVoteInfo(TextVote textVote) {
        voteMapper.updateVoteInfo(textVote);
    }

    @Override
    public int voteResult(int voteId, int index) {
        int result = voteMapper.voteResult(voteId,index);
        return result;
    }

    @Override
    public int voteSelected(int voteId, int index, int userId) {
        int selected =voteMapper.voteSelected(voteId,index,userId);
        return selected;
    }

    @Override
    public int voteSelected(int voteId, int userId) {
        int selected =voteMapper.voteSelected1(voteId,userId);
        return selected;
    }

    @Override
    public void castVote(voteResult voteResult) {
        voteMapper.castVote(voteResult);
    }

    @Override
    public List<voteInfo> getVoteByuserId(int userId) {
        List<voteInfo> voteInfos =voteMapper.getVoteByuserId(userId);
        return voteInfos;
    }
}
